//================================================================================================================================
// number of entries in the tag table
//================================================================================================================================
#define NUM_MTAGS 77

//================================================================================================================================
// code values for Media Cente status changes - these are the codes used in the tag table
//================================================================================================================================
#define DP_FS_DVD 1
#define DP_FS_EXTENSIBILITY 2
#define DP_FS_GUIDE 3
#define DP_FS_HOME 4
#define DP_FS_MUSIC 5
#define DP_FS_PHOTOS 6
#define DP_FS_RADIO 7
#define DP_FS_RECORDEDSHOWS 8
#define DP_FS_TV 9
#define DP_FS_UNKNOWN 10
#define DP_FS_VIDEOS 11

//================================================================================================================================
// Entry numbers in the tag table for each of the possible Media Centre tags
//================================================================================================================================
#define DP_TAG_Application 1
#define DP_TAG_ArtistName 2
#define DP_TAG_CallingPartyName 3
#define DP_TAG_CallingPartyNumber 4 
#define DP_TAG_CD 5
#define DP_TAG_CurrentPicture 6
#define DP_TAG_DialogVisible 7
#define DP_TAG_DiscWriter_ProgressTimeChanged 8
#define DP_TAG_DiscWriter_ProgressPercentageChanged 9
#define DP_TAG_DiscWriter_SelectedFormat 10
#define DP_TAG_DiscWriter_Start 11
#define DP_TAG_DiscWriter_Stop 12
#define DP_TAG_DVD 13
#define DP_TAG_Ejecting 14
#define DP_TAG_EndSession 15
#define DP_TAG_Error 16
#define DP_TAG_FF1 17
#define DP_TAG_FF2 18
#define DP_TAG_FF3 19
#define DP_TAG_FS_DVD 20
#define DP_TAG_FS_Extensibility 21
#define DP_TAG_FS_Guide 22
#define DP_TAG_FS_Home 23
#define DP_TAG_FS_Music  24
#define DP_TAG_FS_Photos 25
#define DP_TAG_FS_Radio 26
#define DP_TAG_FS_RecordedShows 27
#define DP_TAG_FS_TV 28
#define DP_TAG_FS_Unknown 29
#define DP_TAG_FS_Videos 30
#define DP_TAG_GuideLoaded 31
#define DP_TAG_KeyPress 32
#define DP_TAG_MediaName 33
#define DP_TAG_MediaTime 34
#define DP_TAG_MediaTypes 35
#define DP_TAG_MSASPrivateTags 36
#define DP_TAG_Mute 37
#define DP_TAG_Next 38
#define DP_TAG_NextFrame 39
#define DP_TAG_ParentalAdvisoryRating 40
#define DP_TAG_Pause 41
#define DP_TAG_PhoneCall 42
#define DP_TAG_Photos 43
#define DP_TAG_Play 44
#define DP_TAG_Prev 45
#define DP_TAG_PrevFrame 46
#define DP_TAG_PVR 47
#define DP_TAG_Radio 48
#define DP_TAG_RadioFrequency 49
#define DP_TAG_Recording 50
#define DP_TAG_RequestForTuner 51
#define DP_TAG_RepeatSet 52
#define DP_TAG_Rewind1 53
#define DP_TAG_Rewind2 54
#define DP_TAG_Rewind3 55
#define DP_TAG_Shuffle 56
#define DP_TAG_SlowMotion1 57
#define DP_TAG_SlowMotion2 58
#define DP_TAG_SlowMotion3 59
#define DP_TAG_StartSession 60
#define DP_TAG_Stop 61
#define DP_TAG_StreamingContentAudio 62
#define DP_TAG_StreamingContentVideo 63
#define DP_TAG_TitleNumber 64
#define DP_TAG_TotalTracks 65
#define DP_TAG_TrackDuration 66
#define DP_TAG_TrackName 67
#define DP_TAG_TrackNumber 68
#define DP_TAG_TrackTime 69
#define DP_TAG_TransitionTime 70
#define DP_TAG_TVTuner 71
#define DP_TAG_Unknown 72
#define DP_TAG_Visualization 73
#define DP_TAG_Volume 74
#define DP_TAG_TrackTimeLeft 75
#define DP_TAG_ChannelName 76


//================================================================================================================================
// The tag table
//================================================================================================================================
struct mtags {
             char *tag;                 // Tag name
             int  tag_length;           // Length of the tag name
             char *data_type;           // type of the associated value String, Integer or Boolean
             char *description;         // Text description of this tag
             int  istate;               // Associated integer value received for this tag
             char cstate[256];          // Associated string value received for this tag
             int  status_change;        // flag to indicate if this tag constitues a status change (set to code values as above
             char *display;             // what to display for this tag
             } dp_mtags [NUM_MTAGS] =
             {
               {"Status",6,"String","Media Centre Status",0,"Undefined",0,"Status"},
               {"Application",11,"n/a","Not used by components.",0,"Undefined",0,"Unknown"},
               {"ArtistName",10,"String","Name of the artist associated with the current track. This status is sent when the track starts.",0,"Undefined",0,"Unknown"},
               {"CallingPartyName",16,"String","Name of the caller making the incoming phone call.",0,"Undefined",0,"Unknown"},
               {"CallingPartyNumber",18,"Integer","Phone number of the caller making the incoming phone call.",0,"Undefined",0,"Unknown"},
               {"CD",2,"Boolean","CD playback has started.",0,"Undefined",0,"Unknown"},
               {"CurrentPicture",14,"String","Name of the current picture. This status is sent when a new picture is selected.",0,"Undefined",0,"Unknown"},
               {"DialogVisible",13,"Boolean","True if there is a dialogue box open",0,"Undefined",0,"Unknown"},
               {"DiscWriter_ProgressTimeChanged",30,"Integer","Update on the progress of a CD/DVD recording operation, expressed as the amount of time remaining until completion.",0,"Undefined",0,"Unknown"},
               {"DiscWriter_ProgressPercentageChanged",36,"Integer","Update on the progress of a CD/DVD recording operation, expressed as the percentage completed.",0,"Undefined",0,"Unknown"},
               {"DiscWriter_SelectedFormat",25,"DiscFormats","Selected recording format for a CD/DVD recording operation.",0,"Undefined",0,"Unknown"},
               {"DiscWriter_Start",16,"Boolean","CD/DVD recording operation has begun.",0,"Undefined",0,"Unknown"},
               {"DiscWriter_Stop",15,"Boolean","CD/DVD recording operation has concluded.",0,"Undefined",0,"Unknown"},
               {"DVD",3,"Boolean","DVD playback has started.",0,"Undefined",0,"Unknown"},
               {"Ejecting",8,"Boolean","Disc was ejected from the CD/DVD drive. This status is sent only if Windows Media Center was playing the disc.",0,"Undefined",0,"Unknown"},
               {"EndSession",10,"Integer","End of session",0,"Undefined",0,"Unknown"},
               {"Error",5,"Boolean","Error occurred.",0,"Undefined",0,"Unknown"},
               {"FF1",3,"Boolean","Fast forwarding at low speed.",0,"Undefined",0,"Unknown"},
               {"FF2",3,"Boolean","Fast forwarding at medium speed.",0,"Undefined",0,"Unknown"},
               {"FF3",3,"Boolean","Fast forwarding at high speed.",0,"Undefined",0,"Unknown"},
               {"FS_DVD",6,"Boolean","Navigating to Play DVD, or the DVD inset was selected.",0,"Undefined",1,"DVD Playing"},
               {"FS_Extensibility",16,"Boolean","Navigating to a hosted HTML application.",0,"Undefined",2,"Extensibility"},
               {"FS_Guide",8,"Boolean","Navigating to Guide.",0,"Undefined",3,"Guide"},
               {"FS_Home",7,"Boolean","Navigating to Windows Media Center Start page.",0,"Undefined",4,"Main Menu"},
               {"FS_Music",8,"Boolean","Navigating to My Music, or the music inset was selected.",0,"Undefined",5,"Music"},
               {"FS_Photos",9,"Boolean","Navigating to My Pictures.",0,"Undefined",6,"Photos"},
               {"FS_Radio",8,"Boolean","Navigating to Radio.",0,"Undefined",7,"Radio"},
               {"FS_RecordedShows",16,"Boolean","Navigating to Recorded Shows or scheduled recording pages, or the recorded TV inset was selected.",0,"Undefined",8,"Recorded Show"},
               {"FS_TV",5,"Boolean","Navigating to My TV, or the TV inset was selected.",0,"Undefined",9,"TV"},
               {"FS_Unknown",10,"Boolean","Unknown Windows Media Center status.",0,"Undefined",10,"Unknown State"},
               {"FS_Videos",9,"Boolean","Navigating to My Videos, or the video inset was selected.",0,"Undefined",11,"Videos"},
               {"GuideLoaded",11,"Boolean","Downloaded a new guide.",0,"Undefined",0,"Unknown"},
               {"KeyPress",8,"Integer","Key Pressed (Volume up down?)",0,"Undefined",0,"Unknown"},
               {"MediaName",9,"String","Name of the current media. This status is sent when the media starts.",0,"Undefined",0,"Unknown"},
               {"MediaTime",9,"Integer","Length of the current media.",0,"Undefined",0,"Unknown"},
               {"MediaTypes",10,"n/a","Placeholder for enumerated values beginning at 0x2000; not a notification.",0,"Undefined",0,"Unknown"},
               {"MSASPrivateTags",15,"n/a","Placeholder for enumerated values beginning at 0xF000; not a notification.",0,"Undefined",0,"Unknown"},
               {"Mute",4,"Boolean","Muting was turned on or off.",0,"Undefined",0,"Unknown"},
               {"Next",4,"Boolean","Skipping forward to next track or chapter.",0,"Undefined",0,"Unknown"},
               {"NextFrame",9,"Boolean","Skipping forward to next frame while paused.",0,"Undefined",0,"Unknown"},
               {"ParentalAdvisoryRating",22,"String","Parental advisory rating of current show.",0,"Undefined",0,"Unknown"},
               {"Pause",5,"Boolean","Pausing the media.",0,"Undefined",0,"Unknown"},
               {"PhoneCall",9,"Boolean","Incoming phone call.",0,"Undefined",0,"Unknown"},
               {"Photos",6,"Boolean","Picture was selected.",0,"Undefined",0,"Unknown"},
               {"Play",4,"Boolean","Starting to play the current media.",0,"Undefined",0,"Unknown"},
               {"Prev",4,"Boolean","Skipping backward to the previous track or chapter.",0,"Undefined",0,"Unknown"},
               {"PrevFrame",9,"Boolean","Skipping backward to the previous frame while paused.",0,"Undefined",0,"Unknown"},
               {"PVR",3,"Boolean","Starting a recorded show.",0,"Undefined",0,"Unknown"},
               {"Radio",5,"Boolean","Radio or radio frequency scanning has started.",0,"Undefined",0,"Unknown"},
               {"RadioFrequency",14,"String","Current radio frequency. This status is sent when a new radio frequency is selected.",0,"Undefined",0,"Unknown"},
               {"Recording",9,"Boolean","Recording has started.",0,"Undefined",0,"Unknown"},
               {"RequestForTuner",15,"n/a","An application has requested the use of a TV tuner.",0,"Undefined",0,"Unknown"},
               {"RepeatSet",9,"Boolean","Repeat was enabled or disabled.",0,"Undefined",0,"Unknown"},
               {"Rewind1",7,"Boolean","Rewinding at low speed.",0,"Undefined",0,"Unknown"},
               {"Rewind2",7,"Boolean","Rewinding at medium speed.",0,"Undefined",0,"Unknown"},
               {"Rewind3",7,"Boolean","Rewinding at high speed.",0,"Undefined",0,"Unknown"},
               {"Shuffle",7,"Boolean","Shuffle was enabled or disabled.",0,"Undefined",0,"Unknown"},
               {"SlowMotion1",11,"Boolean","Playing at low slow-motion speed.",0,"Undefined",0,"Unknown"},
               {"SlowMotion2",11,"Boolean","Playing at medium slow-motion speed.",0,"Undefined",0,"Unknown"},
               {"SlowMotion3",11,"Boolean","Playing at high slow-motion speed.",0,"Undefined",0,"Unknown"},
               {"StartSession",12,"Integer","End of session",0,"Undefined",0,"Unknown"},
               {"Stop",4,"Boolean","Current media was stopped. This status is sent once when stop is selected, and once when the media has stopped.",0,"Undefined",0,"Unknown"},
               {"StreamingContentAudio",21,"Boolean","Audio content being played back from the hard disk.",0,"Undefined",0,"Unknown"},
               {"StreamingContentVideo",21,"Boolean","Video content being played back from the hard disk.",0,"Undefined",0,"Unknown"},
               {"TitleNumber",11,"Integer","Number of the current title.",0,"Undefined",0,"Unknown"},
               {"TotalTracks",11,"Integer","Total number of tracks on the current media.",0,"Undefined",0,"Unknown"},
               {"TrackDuration",13,"Integer","Duration, in seconds, of the current track.",0,"Undefined",0,"Unknown"},
               {"TrackName",9,"String","Name of the current track.",0,"Undefined",0,"Unknown"},
               {"TrackNumber",11,"Integer","CD track number, DVD chapter number, or TV channel number.",0,"Undefined",0,"Unknown"},
               {"TrackTime",9,"Integer","Elapsed time, in seconds, within the current track. This status is incremented and sent every second.",0,"Undefined",0,"Unknown"},
               {"TransitionTime",14,"Integer","Duration, in seconds, of transitions between slides in a slide show.",0,"Undefined",0,"Unknown"},
               {"TVTuner",7,"Boolean","TV has started.",0,"Undefined",0,"Unknown"},
               {"Unknown",7,"Boolean","Unknown property.",0,"Undefined",0,"Unknown"},
               {"Visualization",13,"Boolean","Visualization has started or stopped.",0,"Undefined",0,"Unknown"},
               {"Volume",6,"Integer","Current volume level. This status is sent when the volume changes.",0,"Undefined",0,"Unknown"},
               {"TrackTimeLeft",13,"Integer","Remaining Track time.",0,"Undefined",0,"Unknown"},
               {"ChannelName",11,"String","TV Channel Name",0,"Undefined",0,"Unknown"}
};

//================================================================================================================================
// Global values
//================================================================================================================================
static char dp_last_line[256];          // Last line received
static int  dp_socket_connected;        // Flag set to 1 if sockets are connected
static char dp_status[80];              // Current status string (HOME etc.
static char dp_prev_status[80];         // Previous status string (HOME etc.
static int  dp_status_value;            // Current status value (FS_HOME etc.
static int  dp_prev_status_value;       // Previous status value
static char dp_display_line_1[256];     // Top line for display 
static char dp_display_line_2[256];     // Bottom line for display
static char dp_tag_value[256];          // tag value for return to dll call
static int  dp_play;                    // Play=1/stop=0, 
static char dp_subtracted[80];          // for return of subtracted value

